package cn.gson.fengboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Zdeliverylog {
    private int deliverylogId;//交付记录id
    private TfyclientForm clientId;//客户
    private Zdelivery deliveryId;//交付计划
    private Timestamp deliverylogTime;//交付记录日期
    private String deliverylogRecipient;//交付记录对方接收人
    private BigDecimal deliverylogNumber;//交付记录产品总金额
    private String deliverylogRemark;//交付记录备注
    private String deliverylogFzr;//交付记录备注
    private List<Zdeliverylogdelivery> zdeliverylogdeliveriesByDeliverylogId;

    @Id
    @Column(name = "deliverylog_id")
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    public int getDeliverylogId() {
        return deliverylogId;
    }

    public void setDeliverylogId(int deliverylogId) {
        this.deliverylogId = deliverylogId;
    }

    @ManyToOne
    @JoinColumn(name = "client_id", referencedColumnName = "client_id")
    public TfyclientForm getClientId() {
        return clientId;
    }

    public void setClientId(TfyclientForm clientId) {
        this.clientId = clientId;
    }

    @ManyToOne
    @JoinColumn(name = "delivery_id", referencedColumnName = "delivery_id")
    public Zdelivery getDeliveryId() {
        return deliveryId;
    }

    public void setDeliveryId(Zdelivery deliveryId) {
        this.deliveryId = deliveryId;
    }

    @Basic
    @Column(name = "deliverylog_time")
    public Timestamp getDeliverylogTime() {
        return deliverylogTime;
    }

    public void setDeliverylogTime(Timestamp deliverylogTime) {
        this.deliverylogTime = deliverylogTime;
    }

    @Basic
    @Column(name = "deliverylog_fzr")
    public String getDeliverylogFzr() {
        return deliverylogFzr;
    }

    public void setDeliverylogFzr(String deliverylogFzr) {
        this.deliverylogFzr = deliverylogFzr;
    }

    @Basic
    @Column(name = "deliverylog_recipient")
    public String getDeliverylogRecipient() {
        return deliverylogRecipient;
    }

    public void setDeliverylogRecipient(String deliverylogRecipient) {
        this.deliverylogRecipient = deliverylogRecipient;
    }

    @Basic
    @Column(name = "deliverylog_number")
    public BigDecimal getDeliverylogNumber() {
        return deliverylogNumber;
    }

    public void setDeliverylogNumber(BigDecimal deliverylogNumber) {
        this.deliverylogNumber = deliverylogNumber;
    }

    @Basic
    @Column(name = "deliverylog_remark")
    public String getDeliverylogRemark() {
        return deliverylogRemark;
    }

    public void setDeliverylogRemark(String deliverylogRemark) {
        this.deliverylogRemark = deliverylogRemark;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Zdeliverylog that = (Zdeliverylog) o;
        return deliverylogId == that.deliverylogId &&
                Objects.equals(clientId, that.clientId) &&
                Objects.equals(deliveryId, that.deliveryId) &&
                Objects.equals(deliverylogTime, that.deliverylogTime) &&
                Objects.equals(deliverylogRecipient, that.deliverylogRecipient) &&
                Objects.equals(deliverylogNumber, that.deliverylogNumber) &&
                Objects.equals(deliverylogRemark, that.deliverylogRemark);
    }

    @Override
    public int hashCode() {
        return Objects.hash(deliverylogId, clientId, deliveryId, deliverylogTime, deliverylogRecipient, deliverylogNumber, deliverylogRemark);
    }


    @OneToMany(mappedBy = "deliverylogId")
    public List<Zdeliverylogdelivery> getZdeliverylogdeliveriesByDeliverylogId() {
        return zdeliverylogdeliveriesByDeliverylogId;
    }

    public void setZdeliverylogdeliveriesByDeliverylogId(List<Zdeliverylogdelivery> zdeliverylogdeliveriesByDeliverylogId) {
        this.zdeliverylogdeliveriesByDeliverylogId = zdeliverylogdeliveriesByDeliverylogId;
    }

    @Override
    public String toString() {
        return "Zdeliverylog{" +
                "deliverylogId=" + deliverylogId +
                ", clientId=" + clientId +
                ", deliveryId=" + deliveryId +
                ", deliverylogTime=" + deliverylogTime +
                ", deliverylogRecipient='" + deliverylogRecipient + '\'' +
                ", deliverylogNumber=" + deliverylogNumber +
                ", deliverylogRemark='" + deliverylogRemark + '\'' +
                ", zdeliverylogdeliveriesByDeliverylogId=" + zdeliverylogdeliveriesByDeliverylogId +
                '}';
    }
}
